/* 
 * $Id$
 *
 *
 * Ryan Boyd 
 *
 *!\file strops.c
 * \brief Implementation for various string operations.
 *
**/

#include "strops.h"

/*!\fn int byte2str(Byte b, char* buf, ByteConvFmt bcf )
 * \brief Turn contents of a \a Byte into a string.
 * \param b The \a byte we want to stringify.
 * \param buf A pointer to storage for the string.
 * \param bcf The conversion format (BIN, OCT, DEC, HEX).
 * \return an \a int (0 if success, error otherwise).
 *
 * This function does not add a terminating null to 
 * \a buf.  For BIN, \a buf should be at least 8 characters
 * wide.
 */
int byte2str(Byte b, char* buf, ByteConvFmt bcf ) {

  Byte mymask = byte_static_init( MASK0 );
  int bshift = 0;
  int buf_pos = 8-1;

  if( buf == NULL ) return 1;

  for( ; bshift<8 ; mymask = 1<<(++bshift), --buf_pos ) {

    switch( bcf ) {

      case BIN:
        buf[buf_pos] = (is_bit_on(&b, mymask) ? '1' : '0');
        break;

      case OCT:
        break;
  
      case DEC:
        break;

      case HEX:
        break;

      default:
        break;

    }

  }

  return(0);

}


